#pragma once
#include<ctime>
#include<cstdio>
#include<pthread.h>

#define INF 0
#define DBG 1
#define ERR 2
#define DEFAULT_LEV ERR//修改日志等级，修改此处。不小于此等级才可打印

#define log(level, format, ...)\
do{\
    if(level >= DEFAULT_LEV) {\
    time_t tm = time(NULL);\
    char tm_arr[32] = {0};\
    strftime(tm_arr, 31, "%H:%M:%S", localtime(&tm));\
    fprintf(stdout, "%p %s[%s:%d] " format "\n", (void*)pthread_self(), tm_arr, __FILE__, __LINE__, ##__VA_ARGS__);\
    }\
}\
while(0)

#define INF_LOG(format, ...)    log(INF, format, ##__VA_ARGS__);
#define DBG_LOG(format, ...)    log(DBG, format, ##__VA_ARGS__);
#define ERR_LOG(format, ...)    log(ERR, format, ##__VA_ARGS__);
